#pragma once
#ifndef DEF_H
#define DEF_H
#include <iostream>
#include <cstdlib>
#include <ctime>
#define MAXSIZE 3000
using namespace std;

class MYINT
{
public:
	int len;
	bool sign;
	unsigned char d[MAXSIZE];
	MYINT() { memset(d, 0, MAXSIZE); sign = 0; };
	~MYINT() {};
	void operator= (const int&);
	void operator= (const MYINT& a);
	void operator= (string s);
	void Clear() { memset(d, 0, MAXSIZE); }
	MYINT Random();
	void RefreshLen();
};
MYINT operator- (const MYINT& a, const MYINT& b);
MYINT operator+ (const MYINT& a, const MYINT& b);
ostream& operator<< (ostream& out, const MYINT& a);
istream& operator>> (istream& in, const MYINT& a);
MYINT operator* (MYINT a, MYINT& b);
MYINT operator%(MYINT a, MYINT& b);
MYINT operator/ (MYINT a, MYINT& b);
bool isPrime(MYINT n);
MYINT niyuan(MYINT a, MYINT b);
MYINT GCD(MYINT a, MYINT b);
bool operator> (const MYINT& a, const MYINT& b);
bool operator< (const MYINT& a, const MYINT& b);
bool operator>= (const MYINT& a, const MYINT& b);
bool operator>= (const MYINT& a, const MYINT& b);
bool operator== (const MYINT& a, const MYINT& b);
bool operator!= (const MYINT& a, const MYINT& b);
MYINT encode(string s, MYINT p, MYINT q);
MYINT RSA_Encode(MYINT m, MYINT e, MYINT n);
MYINT RSA_Decode(MYINT c, MYINT d, MYINT n);
string INT2str(MYINT& c);
string INT2val(MYINT& c);

#endif
